home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok72.lha
/
Env
/
Env.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
4KB
|
139 lines
(*************************************************************************
:Program. Env.mod
:Contents. Shows contents of local and global dos environment variables
:Author. Hartmut Goebel [hG]
:Address. Aufseßplatz 5, D-8500 Nürnberg 40
:Copyright. Public Domain
:Language. Oberon
:Translator. Amiga Oberon V2.25
:History. V1.0, 28 Oct 1991 [hG]
:History. V1.1, 24 Feb 1992 [hG] ^Output: contents now always at col 21
:History. V1.2, 05 Mar 1992 [hG] +template, LocalVars, Flags
:History. V1.3, 12 Apr 1992 [hG] ^flags now always 4-stellig +len
·changed template +version string
:Date. 12 Apr 1992 14:25:38
:Remark. needs AmigaDos 2.0
:Usage. env lo=locals/S, go=globals/S, flags/S, len/S
*************************************************************************)
MODULE Env;
IMPORT
asc: ASCII,
d: Dos,
e: Exec,
(*lst: Lists,*)
ol: OberonLib,
s: SYSTEM;
(*slst: SortedLists;*)
CONST
need20 = "I need at least AmigaDos 2.0\n";
Version = "$VER: env V1.3 (12 Apr 1992) [hG]";
Template = "LO=LOCALS/S,"
"GO=GLOBALS/S,"
"FLAGS/S,"
"LEN/S";
numArguments = 4;
argLocals = 0;
argGlobals = 1;
argFlags = 2;
argLen = 3;
TYPE
EnvVarPtr = POINTER TO EnvVar;
EnvVar = RECORD (*(lst.List)*)
name: ARRAY 30 OF CHAR;
contents: e.STRING;
END;
ARGV = ARRAY numArguments OF LONGINT;
VAR
FileInfo: d.FileInfoBlock;
Lock: d.FileLockPtr;
Env: EnvVar(*Ptr*);
Var: d.LocalVarPtr;
Me: d.ProcessPtr;
Arguments: d.RDArgsPtr;
Argv: ARGV;
b, Sort: BOOLEAN;
BEGIN
IF ol.wbStarted THEN HALT(20); END;
IF d.dos.lib.version < 36 THEN
IF d.Write(d.Output(),need20,SIZE(need20)) = 0 THEN END;
HALT(20);
END;
Me := s.ADR(Version); (* !!dummy!! *)
Me := s.VAL(d.ProcessPtr,ol.Me);
Arguments := d.ReadArgs(Template,Argv,NIL);
IF Arguments = NIL THEN
IF d.PrintFault(d.IoErr(),"env:") THEN END;
HALT(20);
END;
(* No type specified -> show both
*)
IF (Argv[argLocals] = d.DOSFALSE) & (Argv[argGlobals] = d.DOSFALSE) THEN
Argv[argLocals] := d.DOSTRUE;
Argv[argGlobals] := d.DOSTRUE;
END;
IF Argv[argLocals] = d.DOSTRUE THEN
Var := s.VAL(d.LocalVarPtr,Me.localVars.head);
WHILE Var.node.succ # NIL DO
IF Var.node.type = 0 THEN
IF Argv[argLen] = d.DOSTRUE THEN
d.PrintF("%3.3ld ",Var.len);
END;
IF Argv[argFlags] = d.DOSTRUE THEN
d.PrintF("%04.4lx ",s.VAL(INTEGER,Var.flags));
END;
d.PrintF("%-20.20s %s\n",Var.node.name,Var.value);
(*IF d.WriteChars(Var.value^,Var.len) = 0 THEN END;
IF d.PutStr("\n") = 0 THEN END;*)
END;
Var := Var.node.succ;
END;
END;
IF (Argv[argGlobals] = d.DOSTRUE) & (Argv[argLocals] = d.DOSTRUE) THEN
IF d.PutStr("\n") = 0 THEN END;
END;
IF Argv[argGlobals] = d.DOSTRUE THEN
Lock := d.Lock("ENV:",d.sharedLock);
IF Lock = NIL THEN
HALT(20); END;
(*NEW(Env);*)
b := d.Examine(Lock,FileInfo);
REPEAT
b := d.ExNext(Lock,FileInfo);
IF b & (FileInfo.dirEntryType < 0) THEN
(*
IF Sort THEN
IF d.GetVar(FileInfo.fileName,Env.contents,
s.SIZE(e.STRING),LONGSET{d.globalOnly}) > 0 THEN
Env.name := FielInfo.fileName^;
NEW(Env);
END;
ELS*)
IF d.GetVar(FileInfo.fileName,Env.contents,
s.SIZE(e.STRING),LONGSET{d.globalOnly}) > 0 THEN
d.PrintF("%-20.20s %s\n",s.ADR(FileInfo.fileName),s.ADR(Env.contents));
END;
END;
UNTIL (~b) & (d.IoErr() = d.noMoreEntries);
END;
END Env.